<?php
/**
 * 功能：用户信息
 * 
 * 
 */
class UserAction extends CommonAction {
    public function index(){
    }

    //基本信息
    public function info(){
        $User = M("User");
        $vo	= $User->join(' card_user_info on card_user_info.uid=card_user.uid')->getById($_SESSION[C('USER_AUTH_KEY')]);

        $this->assign('vo',$vo);
        $this->display();
    }

    //修改密码页面
    public function password(){
        $this->display();
    }

    // 更换密码
    public function changePwd() {
        //$this->checkUser();
        //对表单提交处理进行处理或者增加非表单数据
        if(md5($_POST['verify']) != $_SESSION['verify']) {
            $this->error('验证码错误！');
        }
        $map = array();
        $map['password']= md5($_POST['oldpassword']);
        if(isset($_POST['user_name'])) {
            $map['user_name'] = $_POST['user_name'];
        }elseif(isset($_SESSION[C('USER_AUTH_KEY')])) {
            $map['uid'] = $_SESSION[C('USER_AUTH_KEY')];
        }
        //检查用户
        $User =  M("User");
        if(!$User->where($map)->field('uid')->find()) {
            $this->error('旧密码不符或者用户名错误！');
        }else {
            $User->password	= md5($_POST['password']);
            $User->save();
            $this->success('密码修改成功！');
         }
    }
}
?>